//
//  KBLikeCollectionViewCell.m
//  喜马拉雅改良版框架
//
//  Created by dllo on 15/12/23.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "KBLikeCollectionViewCell.h"

@implementation KBLikeCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews
{
    _coverLarge = [[UIImageView alloc] init];
//    _coverLarge.backgroundColor = [UIColor orangeColor];
    [self.contentView addSubview:_coverLarge];
    
    [_coverLarge mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.left.right.mas_equalTo(0);
        make.bottom.mas_equalTo(-30);
    }];
    
    UIImageView *myImageView = [[UIImageView alloc] init];
    myImageView.image = [UIImage imageNamed:@"find_cover@2x.png"];
    [_coverLarge addSubview:myImageView];
    
    [myImageView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.right.mas_equalTo(0);
        make.bottom.mas_equalTo(_coverLarge.mas_bottom);
        make.height.mas_equalTo(20);

        
    }];
    
    _title = [[UILabel alloc] init];
    _title.textColor = [UIColor whiteColor];
    _title.text = @"111";
    _title.font = [UIFont systemFontOfSize:12];
    [self.coverLarge addSubview:_title];
    
    [_title mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.right.mas_equalTo(3);
        make.bottom.mas_equalTo(_coverLarge.mas_bottom);
        make.height.mas_equalTo(20);
        
    }];
    
    _imageV = [[UIImageView alloc] init];
    [self.contentView addSubview:_imageV];
    
    [_imageV mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.mas_equalTo(3);
        make.width.mas_equalTo(20);
        make.bottom.mas_equalTo(_coverLarge.mas_bottom);
        make.height.mas_equalTo(20);
    }];
    
    _commentsCounts = [[UILabel alloc] init];
    _commentsCounts.textColor= [UIColor whiteColor];
    _commentsCounts.font = [UIFont systemFontOfSize:12];
    [self.coverLarge addSubview:_commentsCounts];
    
    [_commentsCounts mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.right.mas_equalTo(30);
        make.bottom.mas_equalTo(_coverLarge.mas_bottom);
        make.height.mas_equalTo(20);
        
    }];
    
    
    _trackTitle = [[UILabel alloc] init];
    _trackTitle.text = @"3535235254566645465";
    _trackTitle.numberOfLines = 2;
    _trackTitle.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:_trackTitle];
    
    [_trackTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        
       make.left.right.mas_equalTo(0);
        make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(5);
        make.height.mas_equalTo(35);
    }];
    


}
-(void)setCellDic:(NSDictionary *)cellDic
{
    _trackTitle.text = cellDic[@"trackTitle"];
    _title.text = cellDic[@"title"];
    NSURL *url = [NSURL URLWithString:cellDic[@"coverLarge"]];
    [_coverLarge sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:ImagePlaceHolder]];
    if (cellDic[@"coverMiddle"])
    {
        _trackTitle.text = cellDic[@"title"];
        NSURL *url = [NSURL URLWithString:cellDic[@"coverMiddle"]];
        [_coverLarge sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:ImagePlaceHolder]];
        _title.text = nil;
        _commentsCounts.text = [NSString stringWithFormat:@"%@", cellDic[@"commentsCounts"]];
        _imageV.image = [UIImage imageNamed:@"sound_comments@2x.png"];
    }
    
    
}
@end
